package com.wwzz.controller;

import com.wwzz.model.User;
import com.wwzz.service.UserService;
import org.springframework.stereotype.Controller;

import javax.annotation.Resource;

@Controller
public class UserController1 {
    // 1. 将 UserService 注入到当前类(使用Setter)
    private UserService userService;

    @Resource
    public void setUserService(UserService userService) {
        this.userService = userService;
    }
    // 2. 新建一个方法, 在方法里面调用 UserService 的查询方法. 返回用户对象
    public User findUserById(Integer id){
        if(id == null){
            return null;
        }
        return userService.findUserById(id);
    }
}
